<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%cart}}".
 *
 * @property string $id 购物车 ID
 * @property string $user_id 用户 ID
 * @property string $product_id 产品 ID
 * @property string $quantity 数量
 * @property string $data 数据
 */
class Cart extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%cart}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['id', 'product_id', 'data'], 'required'],
            [['user_id', 'product_id', 'quantity'], 'integer'],
            [['data'], 'string'],
            [['id'], 'string', 'max' => 20],
            [['id'], 'unique'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => '购物车 ID',
            'user_id' => '用户 ID',
            'product_id' => '产品 ID',
            'quantity' => '数量',
            'data' => '数据',
        ];
    }
}
